package per.hx.bs.yw.serviceimpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import per.hx.bs.vo.CountCheckUserVO;
import per.hx.bs.yw.dao.YwAppraisalRecordDao;

import java.util.List;
import java.util.Map;

/**
 * @author HuXing
 * @date 2018/4/28  16:33
 */
@RestController
@RequestMapping(value = "yw-service/count/")
public class YwCountApiServiceImpl {
    private final
    YwAppraisalRecordDao recordDao;

    @Autowired
    public YwCountApiServiceImpl(YwAppraisalRecordDao recordDao) {
        this.recordDao = recordDao;
    }

    /**
     * 获取用户统计信息
     *
     * @param map 条件
     * @return 信息包装集合
     */
    @PostMapping(value = "/check/list")
    public List<CountCheckUserVO> selectListUser(@RequestBody Map<String, Object> map) {
        return recordDao.selectListUserVO(map);
    }

    /**
     * 统计数量
     *
     * @param map 条件
     * @return 数量
     */
    @PostMapping(value = "/check/count")
    public Integer countListUser(@RequestBody Map<String, Object> map) {
        return recordDao.countListUserVO(map);
    }

    /**
     * 指标统计
     *
     * @param map 条件
     * @return 查询结果
     */
    @PostMapping(value = "/appraisal")
    public List<Map<String, Object>> selectListAppraisal(@RequestBody Map<String, Object> map) {
        String dataType = "dataType";
        String user = "USER";
        String dept = "DEPT";
        if (user.equals(map.get(dataType))) {
            return recordDao.selectListAppraisalU(map);
        } else if (dept.equals(map.get(dataType))) {
            return recordDao.selectListAppraisalT(map);
        } else {
            return null;
        }
    }
}
